<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        .box{
            width: 200px;
            height: 200px;
            border: 3px solid #666;
            position: absolute;
            padding: 10px 20px;
            margin: 0 20px;
        }
        .son{
            width: 100px;
            height: 100px;
            background: #70a114;
            margin: 10px 20px;
            padding: 0 20px;
        }
    </style>
</head>
<body>
<div class="box" id="box">
    <div class="son" id="son"></div>
</div>
<script type="text/javascript">
    var box = document.getElementById("box");
    var son = document.getElementById("son");
    console.log(son.offsetParent);//寻找带有定位的父级，如果没有就一直往上找，直到body
    console.log(son.offsetLeft);
    console.log(son.offsetTop);
</script>
</body>
</html>